<?php

namespace App\Jobs;

use App\Services\WxMaterial\WxMaterialService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

/**
 * 微信图文素材拉取
 * @package App\Jobs
 */
class WxMaterialNewsDownload implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $timeout = 120;
    //微信应用ID
    private $appid;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($appid)
    {
        $this->appid = $appid;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $wxMaterialSer = new WxMaterialService($this->appid);
        $wxMaterialSer->createMaterial(WxMaterialService::TYPE_NEWS)->sync();
    }
}
